<?php

namespace app\admin\model;

use think\Model;

class Usermoney extends Model
{
    // 表名
    protected $name = 'user_money_log';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [
        'money_type_text'
    ];
    

    
    public function getMoneyTypeList()
    {
        return ['0' => __('Money_type 0'),'1' => __('Money_type 1'),'2' => __('Money_type 2'),'3' => __('Money_type 3'),'4' => __('Money_type 4'),'5' => __('Money_type 5'),'6' => __('Money_type 6'),'7' => __('Money_type 7'),'8' => __('Money_type 8')];
    }     


    public function getMoneyTypeTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['money_type']) ? $data['money_type'] : '');
        $list = $this->getMoneyTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function user()
    {
        return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }


    public function shoporder()
    {
        return $this->belongsTo('Litestoreshoporder', 'shoporder_id', 'shoporder_id', [], 'LEFT')->setEagerlyType(0);
    }
}
